package com.shunli.cterminal.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.examples.core.mybatis.mapper.KyLambdaQueryWrapper;
import com.shunli.cterminal.entity.StrategyDO;
import com.shunli.cterminal.model.req.StrategyReq;

import java.util.List;

/**
 * 策略配置 Mapper
 *
 * @author 后台管理员
 */
@DS("adEngine")
public interface StrategyMapper extends BaseMapper<StrategyDO> {

    default List<StrategyDO> getStrategyList(StrategyReq reqVO) {
        return selectList(new KyLambdaQueryWrapper<StrategyDO>()
                .eqIfPresent(StrategyDO::getAppId, reqVO.getAppId())
                .likeIfPresent(StrategyDO::getName, reqVO.getName())
                .eqIfPresent(StrategyDO::getStrategyCategoryId, reqVO.getStrategyCategoryId())
                .likeIfPresent(StrategyDO::getStrategyCategoryName, reqVO.getStrategyCategoryName())
                .likeIfPresent(StrategyDO::getStrategyCategoryType, reqVO.getStrategyCategoryType())
                .eqIfPresent(StrategyDO::getAdPlatform, reqVO.getAdPlatform())
               // .eqIfPresent(StrategyDO::getAdAccountIds, reqVO.getAdAccountIds())
                ///.eqIfPresent(StrategyDO::getAdCampaignIds, reqVO.getAdCampaignIds())
                //.eqIfPresent(StrategyDO::getAdGroupIds, reqVO.getAdGroupIds())
                //.eqIfPresent(StrategyDO::getUids, reqVO.getUids())
                //.eqIfPresent(StrategyDO::getStrategyEventId, reqVO.getStrategyEventId())
                //.likeIfPresent(StrategyDO::getStrategyEventIds, reqVO.getStrategyEventIds())
                .eqIfPresent(StrategyDO::getAdType, reqVO.getAdType())
                .eqIfPresent(StrategyDO::getParams, reqVO.getParams())
                .eqIfPresent(StrategyDO::getDescription, reqVO.getDescription())
                .betweenIfPresent(StrategyDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(StrategyDO::getId)
        );
    }

}